void InitQueue(LinkQueue &Q)
{
	Q.front=Q.rear=(QueuePtr)malloc(sizeof(QNode));
	if(!Q.front) exit(-1);
	Q.front->next=NULL;
}
void DestroyQueue(LinkQueue &Q)
{
	while(Q.front)
	{
		Q.rear=Q.front->next;
		free(Q.front);
		Q.front=Q.rear;
	}
}
void ClearQueue(LinkQueue &Q)
{
	DestroyQueue(Q);
	InitQueue(Q);
}
Status QueueEmpty(LinkQueue Q)
{
	if(Q.front->next==NULL)
		return TRUE;
	else
		return FALSE;	
}
int QueueLength(LinkQueue Q)
{
	int i=0;
	QueuePtr p=Q.front;
	while(p!=Q.rear)
	{
		i++;
		p=p->next;	
	}
	return i;
}
Status GetHead(LinkQueue Q,QElemType &e)
{
	QueuePtr p=Q.front->next;
	if(Q.front==Q.rear)
		return ERROR;
	e=p->data;
	return OK;
 } 
 void EnQueue(LinkQueue &Q,QElemType e)
 {
 	QueuePtr p=(QueuePtr)malloc(sizeof(QNode));
 	if(!p) exit(-1);
 	p->data=e;
 	p->next=NULL;
 	Q.rear->next=p;
 	Q.rear=p;
 }
 Status DeQueue(LinkQueue &Q,QElemType &e)
 {
 	QueuePtr p;
 	if(Q.front==Q.rear) return ERROR;
 	p=Q.front->next;
 	e=p->data;
 	Q.front->next=p->next;
 	free(p);
 	return OK;
 }
 void QueueTraverse(LinkQueue Q,void(*visit)(QElemType))
 {
 	QueuePtr p=Q.front->next;
 	while(p)
 	{
	 	visit(p->data);
 		p=p->next;
	 }
 	printf("\n");
 }
 
 
 
 
 
 
 
 
 
 
 
 
